tour <- read_csv("tour.csv", col_names = FALSE) %>%
rename("Year"=X1,"Location"=X2,"Count"=X3)
lo<- function(x) {str_replace_all(x,"合計","地區")}
tour <- tour %>%
mutate(Location=lo(Location))
## 各大洲旅遊人數
tour_continent <- tour %>%
filter(grepl("地區",Location)) %>%
filter(!grepl("其他地區",Location))
## 各大洲旅遊人數比較
ggplot(tour_continent,mapping = aes(x=Year, y=Count))+
geom_point(mapping = aes(color=Location))+
scale_x_continuous(breaks=69:104)
## 旅遊總人數
non_region <- tour %>%
filter(!grepl("地區",Location))
other_region <- tour %>%
filter(grepl("其他地區",Location))
tour_total <- bind_rows(non_region, other_region) %>%
group_by(Year) %>%
summarise(Total=sum(Count,na.rm = TRUE))
## 各大洲+總人數
ggplot()+
geom_line(data=tour_continent,mapping = aes(x=Year,y=Count,color=Location))+
geom_line(data=tour_total, mapping=aes(x=Year,y=Total,color="總人數"))+
scale_x_continuous(limits=c(75,104),breaks=75:104)
92年觀光人數下降,亞洲尤其明顯,所以先看看亞洲
tour_asia_country <- tour %>%
filter(grepl("中國|日本|韓國|香港|亞洲地區|菲律賓|新加坡|馬來西亞|泰國|印尼|汶萊|越南|澳門|緬甸",Location))
gp=ggplot(tour_asia_country,mapping = aes(x=Year, y=Count))+
geom_line(mapping = aes(color=Location))+
scale_x_continuous(limits=c(75,104) ,breaks=75:104)+
scale_y_continuous(breaks=seq(0, 12000000, by=1000000))
ggplotly(gp)
此圖為互動式,可多試試右上角的功能鍵
推測這下跌應與某大事件的發生有關。查詢維基百科2003年臺灣,發現其很有可能與SARS於亞洲地區,特別是臺灣與中國大陸的爆發有關。
民國92年旅遊人數明顯下降,可說是暴跌的程度。其原因應與SARS在中國大陸、香港、澳門及臺灣的爆發有關。
綜上所述,應能確定造成92年旅遊人數下降的因素為SARS疫情爆發。
source('./analysis_code/monthly_h1n1_tour.R')
- 上圖: H1N1按月案例數;下圖: 台灣出國旅遊人數 - 與SARS不同,H1N1對於旅遊似乎沒有影響 -嚴重疫區: 中國、韓國、日本
下圖依據2012年世界航線的資料繪製
目的地為香港之國際航線
library(readr)
library(maps)
library(geosphere)
library(dplyr)
library(stringr)
library(stringi)
rp <- function(x, origin, replace) {stri_replace_all_fixed(x,origin,replace)}
airports <- read_csv("./data/global_airline_network/airports_with_continent.csv")
routes <- read_csv("./data/global_airline_network/routes.csv") %>%
mutate("Source airport ID"=rp(`Source airport ID`,"\\N",NA)) %>%
arrange(desc(`Source airport ID`)) %>%
filter(is.na(`Source airport ID`)==F)
## filter specific airports
Inter_airport <- airports %>%
arrange(desc(`Airport ID`)) %>%
filter(is.na(`Airport ID`)==F) %>%
filter(str_detect(Name, "International Airport|international airport"))
Dest_HK <- routes[routes$`Destination airport ID`=="3077",]
## Originate: HK airport
xlim <- c(-30, 150)
ylim <- c(-60, 85)
map("world", col="black", fill=T, border="white", bg="#FFFFFF00", lwd=0.01, mar = c(0.5,.5,.5,.5), ylim=ylim)
for (i in 1:nrow(Dest_HK)) {
if (Dest_HK[i,]$`Source airport ID` %in% Inter_airport$`Airport ID` & Dest_HK[i,]$`Destination airport ID` %in% airports$`Airport ID`) {
source_air <- Inter_airport[Inter_airport$`Airport ID`==Dest_HK[i,]$`Source airport ID`,]
dest_air <- airports[airports$`Airport ID`==Dest_HK[i,]$`Destination airport ID`,]
inter <- gcIntermediate(c(source_air[1,]$Longitude, source_air[1,]$Latitude), c(dest_air[1,]$Longitude, dest_air[1,]$Latitude), n=100, addStartEnd=TRUE)
lines(inter, col="green", lwd=0.001)
}
}
依據以上方式,應可將目的地為Master card上之城市的航線繪製出來,看看有什麼發現。
此資料僅有航線,並無總載客量
此資料僅2012年